//
//  ViewController.m
//  CJHUDExample
//
//  Created by Chen_Jun on 2017/6/28.
//  Copyright © 2017年 zwu. All rights reserved.
//

#import "ViewController.h"
#import "CJHUD+DIY.h"

#define UISCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
#define UISCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

@interface ViewController ()

@end

@implementation ViewController

- (UIButton *)HUDButtonWithTitle:(NSString *)title center:(CGPoint)center
{
    UIButton *button = [[UIButton alloc] init];
    [button setImage:[UIImage imageNamed:@"CJ_HUD"] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    [button sizeToFit];
    [button setCenter:center];
    [button setBounds:CGRectMake(0, 0, button.bounds.size.width + 10, button.bounds.size.height + 10)];
    [button.layer setBorderColor:[UIColor blackColor].CGColor];
    [button.layer setBorderWidth:2.0];
    [button.layer setCornerRadius:5.0];
    return button;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIButton *smileButton = [self HUDButtonWithTitle:@"-笑脸" center:CGPointMake(UISCREEN_WIDTH * 0.5, 100)];
    [self.view addSubview:smileButton];
    [smileButton addTarget:self action:@selector(smileAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *cryButton = [self HUDButtonWithTitle:@"-哭脸" center:CGPointMake(UISCREEN_WIDTH * 0.5, 175)];
    [self.view addSubview:cryButton];
    [cryButton addTarget:self action:@selector(cryAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *errorButton = [self HUDButtonWithTitle:@"-打叉" center:CGPointMake(UISCREEN_WIDTH * 0.5, 250)];
    [self.view addSubview:errorButton];
    [errorButton addTarget:self action:@selector(errorAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *successButton = [self HUDButtonWithTitle:@"-打钩" center:CGPointMake(UISCREEN_WIDTH * 0.5, 325)];
    [self.view addSubview:successButton];
    [successButton addTarget:self action:@selector(successAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *nullButton = [self HUDButtonWithTitle:@"-没图" center:CGPointMake(UISCREEN_WIDTH * 0.5, 400)];
    [self.view addSubview:nullButton];
    [nullButton addTarget:self action:@selector(nullAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *ingButton = [self HUDButtonWithTitle:@"-菊花（转圈）" center:CGPointMake(UISCREEN_WIDTH * 0.5, 475)];
    [self.view addSubview:ingButton];
    [ingButton addTarget:self action:@selector(ingAction:) forControlEvents:UIControlEventTouchUpInside];
    
}


- (void)smileAction:(id)sender {
    [CJHUD showHUDText:@"就算回家种田，依然保持微笑" forHUDType:HUDTypeSmile];
}

- (void)cryAction:(id)sender {
    [CJHUD showHUDText:@"就算回家种田，依然保持微笑" forHUDType:HUDTypeCry];
}

- (void)errorAction:(id)sender {
    [CJHUD showHUDText:@"就算回家种田，依然保持微笑" forHUDType:HUDTypeError];
}

- (void)successAction:(id)sender {
    [CJHUD showHUDText:@"就算回家种田，依然保持微笑" forHUDType:HUDTypeSuccess];
}

- (void)nullAction:(id)sender {
    [CJHUD showHUDText:@"就算回家种田，依然保持微笑" forHUDType:HUDTypeNull];
}

- (void)ingAction:(id)sender {
    [CJHUD showMessage:@"就算回家种田，依然保持微笑"];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [CJHUD hideHUD];
    });
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
